#include <func.h>

int main()
{
    if(!fork())
    {
        printf("child: pid :%d , pgid: %d, sid: %d\n",getpid()\
               ,getpgid(0),getsid(0));
        setsid();
        chdir("/");
        umask(0);
        printf("child,after setsid: pid :%d , pgid: %d, sid: %d\n",getpid()\
               ,getpgid(0),getsid(0));
        printf("close stdi/o ,print syslog...\n");
        for(int i = 0;i<4;++i)
            close(i);
        int counter= 0 ;
        while(1)
        {
            syslog(LOG_INFO,"%d : i am shuaige",counter++);
            sleep(2);
        }

    }
    else
    {
        printf("parent: pid :%d , pgid: %d, sid: %d\n",getpid()\
               ,getpgid(0),getsid(0));
        return 0;
    }
    return 0;
}

